package pixeleditor.gui;

import java.awt.Dimension;
import java.util.ResourceBundle;

import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerListModel;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeListener;

import common.i18n.ChangeLanguage;
import common.i18n.IChangeLanguage;

import pixeleditor.ctrl.ControlFactory;

@SuppressWarnings("serial")
public class ChooseBrushSizePanel extends JPanel implements IChangeLanguage {

	private JSpinner js;
	
	public ChooseBrushSizePanel() {
		ChangeLanguage.addObserver(this);
		initComponents();
		initControls();		
	}
	
	private void initComponents() {
		setPreferredSize(new Dimension(70,70));
		Integer[] brushSizes = {1,2,3,4,5,6};
		SpinnerListModel bs = new SpinnerListModel(brushSizes);
		js = new JSpinner(bs);
		setLanguage(ChangeLanguage.currentLanguage);
		add(js);
	}
	private void initControls() {
		ChangeListener cl = (ChangeListener) ControlFactory.getControl(ControlFactory.CHOOSE_BRUSH_SIZE_CTRL);
		js.addChangeListener(cl);
	}
	
	
	@Override
	public void setLanguage(ResourceBundle rb) {
		setBorder(new TitledBorder(rb.getString("editorBrush")));
	}

}
